<template>
  <div>
    <!-- 表单 -->
    <el-form ref="form" :model="user" label-width="80px">
      <el-form-item label="ID">
        <el-input v-model="user.userId" />
      </el-form-item>

      <el-form-item label="用户名">
        <el-input v-model="user.username" />
      </el-form-item>
      <el-form-item label="密码">
        <el-input v-model="user.password" />
      </el-form-item>
      <el-form-item label="姓名">
        <el-input v-model="user.name" />
      </el-form-item>

      <!-- <el-form-item label="性别">
        <el-input v-model="user.sex" />
      </el-form-item> -->
      <el-form-item label="测试性别">
        <el-radio-group v-model="user.sex">
          <el-radio v-if="user.sex === 1" label="1" />
          <el-radio v-else label="0" />
        </el-radio-group>
      </el-form-item>

      <!-- <el-table-column prop="enable" label="性别">
        <template slot-scope="scope">
          <el-tag v-if="scope.row.sex === 1">男</el-tag>
          <el-tag v-else type="info">女</el-tag>
        </template>
      </el-table-column> -->

      <el-form-item label="头像">
        <el-input v-model="user.header" />
      </el-form-item>
      <el-form-item label="昵称">
        <el-input v-model="user.nickname" />
      </el-form-item>
      <el-form-item label="邮箱">
        <el-input v-model="user.userEmail" />
      </el-form-item>

      <el-form-item>
        <el-button type="primary" @click="onSubmit">立即修改</el-button>
        <el-button>取消</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
// 引入接口API
import userApi from '@/api/admin'
export default {
  props: {
    user: {
      type: Object,
      default: null
    }
  },
  methods: {
    onSubmit() {
      userApi.update(this.user).then(Response => {
        this.$message.success(Response.msg)
        this.$emit('closeUpdateDialog')
        this.$emit('getUserList')
      })
    }
  }
}
</script>
<style scoped>
.container{
  margin: 20px 35px;
}
</style>
